#include "tokenrender.h"
#include "TokenColors.h"
#include "tokensettings.h"
TokenRender::TokenRender()
{

}

/**
 * @brief 根据输入得到带颜色格式的输出
 * @param itmes
 * @return
 */
std::string TokenRender::render(const TokenParserItems &itmes)
{
      std::string ret;
      for(const TokenParserItem& item : itmes.items){
          const std::string& token = item.token;
          int color = item.color;
          if(color!=-1){
              ret += logCommands[color];
          }else {
              ret += logCommands[enumToInt(LogType::Reset)];
          }
          ret += token;
      }
      return ret;
}

std::string TokenRender::render(const std::string &text)
{
    TokenParserItems items;
    TokenParser::parse(text, items, TokenSettings::shareInstance()->getTokenInfos());
    return TokenRender::render(items);
}

bool TokenRender::isExclude(const std::string &text)
{
    return TokenParser::isExclude(text, TokenSettings::shareInstance()->getExcludeList());
}


